/***************************************************************************
 *   Copyleft 2008-2009 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>									   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#ifndef __LOGGER_H__
#define __LOGGER_H__

#include <windows.h>
#include <iostream>
#include <ostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <fcntl.h>
#include <io.h>
#include "../Utils/vString.h"
#include "../Macros/vMemoryMacros.h"

namespace Vendetta {
	typedef std::ofstream Output;


	class vLogger {
	public:
		/**************************************************************
		* Constructors                                                *
		***************************************************************/
		vLogger(vChar* fileName = "logs.txt"): mFileName(fileName) { }
		~vLogger() { }

		/**************************************************************
		* Other helpful functions                                     *
		***************************************************************/
		vVoid Info(const vChar * print, ...);
		vVoid Debug(const vChar * print, ...);
		vVoid Error(const vChar * print, ...);
		vVoid Warning(const vChar * print, ...);
		vVoid Open(vBool bRedirect = true);
		vVoid Close();

	private:
		vVoid printTime();
		vVoid clearBuffer();
		vVoid clearTimeBuffer();
		vVoid setColor(vUShort color = (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE));
		vVoid printLogHeader();
		vVoid printLogConsoleHeader();

	private:	
		static vChar mTimeBuffer [14];
		static vChar mBuffer [4096];
		HANDLE mhConsoleWnd;
		Output mOutput;
		vBool mRedirect;
		vString mFileName;
	};
}

#endif	//__LOGGER_H__